16. 多类别分类与Softmax 函数
多类别分类和 Softmax
Quiz - Softmax
Softmax 函数
在下个视频中,我们将学习激活函数的对等形式,它和 s 型函数是对等的,但是问题具有 3 个或更多个类别。
DL 18 Q Softmax V2
Softmax Quiz
SOLUTION:
exp练习:编写 Softmax
现在该你来操作了!我们用 Python 编写 Softmax 公式吧。
Softmax 公式:

Start Quiz:
import numpy as np
# Write a function that takes as input a list of numbers, and returns
# the list of values given by the softmax function.
def softmax(L):
pass
import numpy as np
def softmax(L):
expL = np.exp(L)
sumExpL = sum(expL)
result = []
for i in expL:
result.append(i*1.0/sumExpL)
return result
# Note: The function np.divide can also be used here, as follows:
# def softmax(L):
# expL = np.exp(L)
# return np.divide (expL, expL.sum())